package com.lgc.demo.example.prizedraw;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 抽奖，共6张卡（用1-6表示卡类型），每天默认可抽3张卡，最多抽5张
 * 第一天抽的前3张必有一张重复
 * 第二天抽的前3张必有一张重复
 * 抽到第10张必抽全6张不同卡。
 */
public class Program {
    public static void main(String[] args) {
        Set<Integer> haveCardTypes = new HashSet<>();
        int haveCardHistoryCount = 0;
        List<String> dayList = new ArrayList<>();

        CalculateCard calculateCard = new CalculateCard();

        for (int i = 1; i < 7; i++) {
            List<UserCard> userCardList = calculateCard.getList(i);
            if (userCardList != null && !userCardList.isEmpty()) {
                haveCardTypes.add(i);
                haveCardHistoryCount += userCardList.size();
                for (UserCard item :
                        userCardList) {
                    if (!dayList.contains(item.getCreateTime())) {
                        dayList.add(item.getCreateTime());
                    }
                }
            }
        }

        int whichDay = 1;
        String todayDateString = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        if (dayList.contains(todayDateString)) {
            whichDay = dayList.size();
        } else {
            whichDay++;
        }

        int newCardType = calculateCard.draw(whichDay, haveCardTypes, haveCardHistoryCount);
    }
}
